#pragma once

#include <stdint.h>
#include <string>

#include "memory_object_pool.h"

class Message
{
public:
    Message(uint32_t id, const std::string &name = "");
    Message(const Message &other);
    Message(Message &&other);
    ~Message();

    Message &operator=(const Message &other);
    Message &operator=(Message &&other);

    uint32_t id() const;

    const std::string &name() const;

    // const std::vector<uint8_t> &data() const;
    // void setData(const std::vector<uint8_t> &data);
    // void setData(std::vector<uint8_t> &&data);

    uint8_t *data();
    size_t size() const;

    template<typename T>
    T *castTo() {
        return m_data->castTo<T>();
    }

    bool fill(uint8_t *data, size_t size, size_t offset = 0);

private:
    uint32_t m_id;
    std::string m_name;
    std::unique_ptr<MemoryObject> m_data;
};

